home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / scrolvb / scroll_x.frm < prev   
Text File  |  1996-06-12  |  3KB  |  106 lines

  1. VERSION 2.00
  2. Begin Form frmScroll 
  3.    BackColor       =   &H00FFFF00&
  4.    BorderStyle     =   0  'None
  5.    Caption         =   "frmScroll"
  6.    ClientHeight    =   615
  7.    ClientLeft      =   2580
  8.    ClientTop       =   3780
  9.    ClientWidth     =   3975
  10.    ControlBox      =   0   'False
  11.    Height          =   1020
  12.    Left            =   2520
  13.    LinkTopic       =   "Form2"
  14.    MaxButton       =   0   'False
  15.    MDIChild        =   -1  'True
  16.    MinButton       =   0   'False
  17.    ScaleHeight     =   41
  18.    ScaleMode       =   3  'Pixel
  19.    ScaleWidth      =   265
  20.    Top             =   3435
  21.    Width           =   4095
  22.    Begin CommandButton cmdHome 
  23.       Caption         =   "Home"
  24.       Height          =   375
  25.       Index           =   0
  26.       Left            =   2040
  27.       TabIndex        =   1
  28.       Top             =   120
  29.       Width           =   1815
  30.    End
  31.    Begin CommandButton cmdStart 
  32.       Caption         =   "Click To Start"
  33.       Height          =   375
  34.       Left            =   120
  35.       TabIndex        =   0
  36.       Top             =   120
  37.       Width           =   1815
  38.    End
  39. End
  40.  
  41. ' scroll_X.FRM - Declarations.
  42.  
  43.     DefInt A-Z
  44.  
  45. ' End Of Declarations.
  46.  
  47. Sub cmdHome_Click (Index As Integer)
  48.  
  49. ' All of these buttons just move the scrolling form back up to the upper
  50. ' left corner, where it was before you started scrolling.
  51.  
  52.     frmScroll.Move 0, 0
  53.  
  54. End Sub
  55.  
  56. Sub cmdStart_Click ()
  57.  
  58. ' Hide this button right away.
  59.  
  60.     cmdStart.Visible = False
  61.  
  62. ' These are the PIXEL sizes that the scrolling form will be. Any number
  63. ' up to 32000 is alright. Over that size, things get flakey!
  64.  
  65.     GoalWidth = 400
  66.     GoalHeight = 400
  67.  
  68. ' Since the MDI child form external size is "Twips", you must convert the
  69. ' pixel goal to Twips, and THEN actually change the form size. In other
  70. ' words, when you give VB a Width or Height value, it expects a Twip value.
  71. '
  72. ' To get this Twip value, you multiply your pixel size goal times the
  73. ' "number of Twips per pixel". VB has a built-in "Screen" object that will
  74. ' give you that number (it varies with different monitor types).
  75.  
  76.     frmScroll.Width = GoalHeight * Screen.TwipsPerPixelX
  77.     frmScroll.Height = GoalHeight * Screen.TwipsPerPixelY
  78.  
  79. ' Now duplicate the "Home" command button a few times, just to have some
  80. ' other sample controls on the form. These are not critical, and can be
  81. ' removed and replaced with any other kind of control.
  82.  
  83.     For temp = 1 To 15
  84.     Load cmdHome(temp)
  85.     Next temp
  86.  
  87. ' Adjust all of the cmdHome buttons, including #0, which was on the form
  88. ' at design time.
  89.  
  90.     For x = 0 To 3
  91.     For y = 0 To 3
  92.         ' Figure out which one to move (0 to 15).
  93.         temp = (y * 4) + x
  94.         ' Calculate new location.
  95.         offsetX = 10 + (x * 100)
  96.         offsetY = 30 + (y * 100)
  97.         ' Move it, change caption, and show it.
  98.         cmdHome(temp).Move offsetX, offsetY, 80, 40
  99.         cmdHome(temp).Caption = "Home #" + Trim(temp)
  100.         cmdHome(temp).Visible = True
  101.     Next y
  102.     Next x
  103.  
  104. End Sub
  105.  
  106.